package cn.com.surker.excel;

/**
 * @Author lucky
 * @create 2024年12月30 22:02
 * @desc
 */
public class CellUtils {


    public static void main(String[] args){
        System.out.println(convertCellCode(9));
    }
    public static String convertCellCode(Integer size) {
        if (size < 1)
            return "";
        String code = "";
        Integer num = size / 26;
        if (num > 0)
            code = convertLetter(num);
        String letter = convertLetter(size % 26);
        code += letter;
        return code;
    }

    public static String  convertLetter(Integer size) {
        switch (size) {
            case 1:
                return "A";
            case 2:
                return "B";
            case 3:
                return "C";
            case 4:
                return "D";
            case 5:
                return "E";
            case 6:
                return "F";
            case 7:
                return "G";
            case 8:
                return "H";
            case 9:
                return "I";
            case 10:
                return "J";
            case 11:
                return "K";
            case 12:
                return "L";
            case 13:
                return "M";
            case 14:
                return "N";
            case 15:
                return "O";
            case 16:
                return "P";
            case 17:
                return "Q";
            case 18:
                return "R";
            case 19:
                return "S";
            case 20:
                return "T";
            case 21:
                return "U";
            case 22:
                return "V";
            case 23:
                return "W";
            case 24:
                return "X";
            case 25:
                return "Y";
            case 26:
                return "Z";
            default:
                return "A";
        }
    }

}
